package com.kx.center.email;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MailSendClient {

	 @SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception {
	      ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
	         
	        ArrayList<Map<String, Object>> array = new ArrayList<>();
	        Map<String, Object> model1 = new HashMap<>();
	        model1.put("templateName", "sendMailByVelocityTemplate");
	        model1.put("username", "scott  li");
	        model1.put("recipient", "scott.li@4chen.cn");
	        
	        Map<String, Object> model2 = new HashMap<>();
	        model2.put("templateName", "sendForgetPwdMail");
	        model2.put("username", "limenglong");
	        model2.put("url", "http:www.baidu.com");
	        model2.put("recipient", "623904391@qq.com");
	        
	        model2.putAll(model1);
	        
	        //{templateName=sendForgetPwdMail, recipient=scott.li@4chen.cn, username=scott  li}
	        array.add(model1);
	        array.add(model2);
	        for(int i=0 ;i<array.size() ;i++){
	        	Map<String, Object> map = array.get(i);
	        	String templateName = (String) map.get("templateName");
	        	SendMailBase sendMailImpl = (SendMailBase) context.getBean(templateName);
	 	       	
	        	sendMailImpl.sendMail(map);
	        }
	      
	   }
}
